﻿using MvcArchStarter.Domain;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;

namespace MvcArchStarter.Infrastructure.Persistence
{
    public class TestDataInitializer : CreateDatabaseIfNotExists<MvcArchStarterContext>
    {
        protected override void Seed(MvcArchStarterContext context)
        {

            Blog blog1 = new Blog { Name = "Blog1", Title = "Blog 1" };
            
            Post blog1Post1 = new Post { Content = "Blog 1 Post 1 Content", DatePosted = DateTime.Now, Title = "Blog 1 Post 1 Title" };
            Post blog1Post2 = new Post { Content = "Blog 1 Post 2 Content", DatePosted = DateTime.Now, Title = "Blog 1 Post 2 Title" };
            blog1.Posts = new List<Post>() { blog1Post1, blog1Post2 };
            context.Blogs.Add(blog1);

            Blog blog2 = new Blog { Name = "Blog2", Title = "Blog 2" };

            Post blog2Post1 = new Post { Content = "Blog 2 Post 1 Content", DatePosted = DateTime.Now, Title = "Blog 2 Post 1 Title" };
            Post blog2Post2 = new Post { Content = "Blog 2 Post 2 Content", DatePosted = DateTime.Now, Title = "Blog 2 Post 2 Title" };
            blog2.Posts = new List<Post>() { blog2Post1, blog2Post2 };

            context.Blogs.Add(blog2);

            context.SaveChanges();
        }
    }
}
